/**
 * 
 */
package com.alstudio.utils.user;

import java.util.ArrayList;

import android.content.Context;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.alstudio.app.ALLocalEnv;
import com.alstudio.pojo.module.user.User;
import com.alstudio.utils.formater.sex.ALSexFormatter;
import com.loovee.imaohu.R;

/**
 * 根据User对象的不同属性，显示不同的icon
 * 
 * @author alonso lee
 * 
 */
public class UserIconsUtil {

	/**
	 * 顯示性別之類的圖標
	 */
	public static void setupIconsLayout(LinearLayout parent, User u, Context ctx) {
		ArrayList<Integer> icons = new ArrayList<Integer>();
		parent.removeAllViews();

		icons.add(ALSexFormatter.transSexBigDrawable(u.getSex()));
		if (u.isVauthed()) {
			icons.add(R.drawable.find_user_icon_vip_big);
		}
		for (int i = 0; i < icons.size(); i++) {
			ImageView oView = new ImageView(ctx);
			if (i > 0) {
				oView.setPadding(3, 0, 3, 0);
			} else {
				oView.setPadding(0, 0, 3, 0);
			}

			oView.setImageResource(icons.get(i));
			parent.addView(oView);
		}
	}
	
	/**
	 * 顯示性別之類的圖標
	 */
	public static void setupIconsLayout(LinearLayout parent, User u) {
		ArrayList<Integer> icons = new ArrayList<Integer>();
		parent.removeAllViews();

		icons.add(ALSexFormatter.transSexBigDrawable(u.getSex()));
		if (u.isVauthed()) {
			icons.add(R.drawable.find_user_icon_vip_big);
		}
		for (int i = 0; i < icons.size(); i++) {
			ImageView oView = new ImageView(ALLocalEnv.getLocalEnv());
			if (i > 0) {
				oView.setPadding(3, 0, 3, 0);
			} else {
				oView.setPadding(0, 0, 3, 0);
			}

			oView.setImageResource(icons.get(i));
			parent.addView(oView);
		}
	}
	
}
